Lab 00 - ROS recap
Robotics II
Poznan University of Technology, Institute of Robotics and Machine Intelligence
Laboratory 0: A recap of Robot Operating System (ROS) usage
Back to the course table of contents
Installation
The installation steps for ROS are available in the following links: ROS Melodic for Ubuntu 18.04 or ROS Noetic for Ubuntu 20.04.
Alternatively, you can use prepared containers: osrf/ros:noetic-desktop-full
or osrf/ros:melodic-desktop-full
.
Basic concepts
Source: https://trojrobert.github.io/hands-on-introdution-to-robot-operating-system(ros)/
Usage
Below are some tips to remind you how to use ROS in the terminal.
Workspace
Frequently, all ROS-related activities are performed in the created directory: ~/catkin_ws/
. In this example, the ~/catkin_ws/src/
subdirectory contains the project codes.
- When you want to build ROS nodes, invoke the following command from the
~/catkin_ws/
directory:
catkin_make
- If the compilation was successful, source the environment variables. Note that you must do this for every console individually.
source devel/setup.bash
Executions
- Use
roscore
to start the robotic operating system.
roscore
- Use
roslaunch
to start the node.
roslaunch <PACKAGE_NAME> <LAUNCH_FILE_NAME>
i.e. roslaunch fsds_ros_bridge fsds_ros_bridge.launch
- Use
rosrun
to execute the ROS script.
rosrun <PACKAGE_NAME> <EXEC_FILE_NAME>
i.e. rosrun fsds_ros_bridge cameralauncher.py
Topics
- Display a list of available topics.
rostopic list
for example:
$ rostopic list
/fsds/camera/cam_mono
/fsds/control_command
/fsds/gps
- View information about the selected topic.
rostopic info <TOPIC_NAME>
for example:
$ rostopic info /fsds/gps
Type: sensor_msgs/NavSatFix
Publishers:
* /fsds/ros_bridge (http://bartosz-PC:44941/)
Subscribers: None
- Read the topic message.
rostopic echo <TOPIC_NAME>
for example:
$ rostopic echo /fsds/gps
header:
seq: 2999
stamp:
secs: 1645038420
nsecs: 22534000
frame_id: "fsds/FSCar"
status:
status: 0
service: 0
latitude: 47.6414679993
longitude: -122.140165
altitude: 122.246520996
position_covariance: [0.0015999999595806003, 0.0, 0.0, 0.0, 0.0015999999595806003, 0.0, 0.0, 0.0, 0.0015999999595806003]
position_covariance_type: 0
---
- Publish the topic message
rostopic pub <TOPIC_NAME> <MESSAGE_TYPE> <MESSAGE>
for example:
$ rostopic pub /fsds/control_command fs_msgs/ControlCommand "header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: ''
throttle: 0.0
steering: 0.0
brake: 0.0"
Services
- Display a list of available services.
rosservice list
for example:
$ rosservice list
/fsds/reset
/fsds/ros_bridge/get_loggers
- View information about the selected topic.
rosservice info <SERVICE_NAME>
for example:
$ rosservice info /fsds/reset
Node: /fsds/ros_bridge
URI: rosrpc://bartosz-PC:57451
Type: fsds_ros_bridge/Reset
Args: waitOnLastTask
- Call up a specific service.
rosservice call <SERVICE_NAME> <DATA>
for example:
$ rosservice call /fsds/reset "waitOnLastTask: false"
success: False
Tools
Rosbag
Rosbag allows you to record (rosbag record
) and replay (rosbag play
) the status of your robotic system.
Rviz
Rviz allows you to visualise topics.
$ rosrun rviz rviz
Rqt_plot
Rqt_plot allows you to draw graphs for topics.
$ rosrun rqt_plot rqt_plot
Rqt_graph
Rqt_graph allows the graphical visualisation of topical calls.
$ rosrun rqt_graph rqt_graph